package com.homwee.tvap.common.comSettingInterface;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

import android.content.Context;
import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.Log;

//zcj 2018-10-30 import com.changhong.android.tvapi.common.vo.CHMWVersion;
//zcj 2018-10-30 import com.changhong.android.tvapi.common.vo.PanelInfo;
//zcj 2018-10-30 import com.changhong.android.tvapi.dtv.vo.TVOSVersion;
import com.homwee.factory.R;
import com.homwee.factory.util.Contants;
//import com.changhong.itv.TvInfoCollect.InfoCollectFile;
//import com.changhong.tvos.common.MiscManager;
//import com.changhong.tvos.common.SystemManager;
//import com.changhong.tvos.common.TVManager;
//import com.changhong.tvos.model.CHMWVersion;
//import com.changhong.tvos.model.PanelInfo;
//import com.changhong.tvos.model.TVOSVersion;
//zcj 2018-10-30 import com.changhong.tvos.service.TvMiscManager;
import com.homwee.tvap.common.srvfunc.FactorySetting;
import com.mediatek.twoworlds.factory.MtkTvFApiDisplay;
import com.mediatek.twoworlds.factory.MtkTvFApiInformation;
import com.mediatek.twoworlds.factory.MtkTvFApiSystem;
import com.mediatek.twoworlds.factory.common.MtkTvFApiKeyManager;
import com.homwee.factory.ProductFun;
import com.mediatek.twoworlds.tv.MtkTvCI;


//first page 
public class factoryPage1 {
    static String TAG = "factory";
    // private static MiscManager miscManager;
    // private SystemManager mSystemManager;

    // private TvMiscManager mTvMiscManager = null;
    MtkTvFApiDisplay mMtkTvFApiDisplay = null;
    MtkTvFApiInformation mMtkTvFApiInformation = null;
    MtkTvFApiSystem mMtkTvFApiSystem = null;

    Context mContext = null;

    static factoryPage1 Interface = null;
    MenuConfigManager mCfg = MenuConfigManager.getInstance(null);
    //public final static String mProduct=ProductFun.getProduct();
    public final static String mProduct=SystemProperties.get("ro.product.name", "");

    private factoryPage1(Context context) {
        mContext = context;
        // TVManager tvManager = TVManager.getInstance(context);
        try {
            // mSystemManager =tvManager.getSystemManager();
            // miscManager = tvManager.getMiscManager();

            // mTvMiscManager =TvMiscManager.getInstance();
            mMtkTvFApiDisplay = MtkTvFApiDisplay.getInstance();
            mMtkTvFApiInformation = MtkTvFApiInformation.getInstance();
            mMtkTvFApiSystem = MtkTvFApiSystem.getInstance();
        } catch (Exception e) {
            // TODO: handle exception
            Log.v("tv", "miscManager ==null");
        }
    }

    public static factoryPage1 getInstance(Context context) {
        if (Interface == null) {
            Interface = new factoryPage1(context);
        }
        return Interface;
    }

    public String getSWVersion() {
        String version = null;
        //if (mMtkTvFApiInformation != null) {
        version = SystemProperties.get("vendor.cus.product.fw.version", "");
        if(TextUtils.isEmpty(version)){
            Log.v(TAG,"get vendor.cus.product.fw.version faill");
            version=SystemProperties.get("ro.vendor.oemname","");
        }
        Log.v(TAG, "getSWVersion =" + version);
        return version;
    }

    public String getSWDate() {
        String version = null;
        // version = SystemProperties.get("ro.build.chver", "");
        version = SystemProperties.get("ro.vendor.build.date", "");
        if (version.length() > 0) {
            // version = version.substring(version.length() - 19);
        }
        return version;
    }

    public int getProductNum() {
        int number = 0;
        // zcj 2018-10-30 if(mTvMiscManager !=null){
        // number =miscManager.getSupportProductNum();
        // zcj 2018-10-30 }
        Log.v(TAG, "getProductNum =" + number);
        return number;
    }

    public int getProductIndex() {
        int index = 0;
        // zcj 2018-10-30 if(mTvMiscManager !=null){
        // index =miscManager.getCurrentProductIndex();
        // zcj 2018-10-30 }
        Log.v(TAG, "getProductIndex =" + index);
        return index;
    }

    public String getProductName() {
        String name = "ProductSimple";
        // zcj 2018-10-30 if(mTvMiscManager !=null){
        // zcj 2018-10-30 name =mTvMiscManager.getProductName();
        // zcj 2018-10-30 }
        if (name == null) {
            name = "unknow";
        }
        Log.v(TAG, "getProductName =" + name);
        return name;
    }

    public boolean setProductIndex(int value) {
        boolean bResult = false;
        Log.v(TAG, "setProductIndex =" + value);
        // zcj 2018-10-30 if(mTvMiscManager !=null){
        // bResult =miscManager.selectProductWithIndex(value);
        // zcj 2018-10-30 }

        return bResult;
    }

    public int getPanelNum() {
        int number = 0;
        // zcj 2018-10-30 if(mTvMiscManager !=null){
        // number =miscManager.getSupportPanelNum();
        // zcj 2018-10-30 }
        // zcj 2018-10-30 Log.v(TAG,"getPanelNum ="+number);
        return number;
    }

    public int getPanelIndex() {
        int index = 0;
        // zcj 2018-10-30 if(mTvMiscManager !=null){
        // index =miscManager.getCurrentPanelIndex();
        // zcj 2018-10-30 }
        Log.v(TAG, "getPanelIndex =" + index);
        return index;
    }

    public String getPanelName() {
        String tempString = "null";
        // zcj 2018-10-30 return mTvMiscManager.getPanelName();
        tempString = mMtkTvFApiDisplay.getPanelIni();
        if (!TextUtils.isEmpty(tempString)) {
            return tempString.substring(tempString.lastIndexOf("/") + 1,
                    tempString.lastIndexOf("."));
        } else {
            return "null";
        }

        //
    }

    public void savePanelName(String name) {
        if (name != null) {
            // zcj 2018-10-30 mTvMiscManager.setPanelName(name);
			/*mMtkTvFApiInformation.setIniParameter(
					Contants.FACTORY_PAGE2_CUSTOMER_PATH,
					Contants.FACTORY_INI_PANEL_PATH,
					"/vendor/tvconfig/config/panel/" + name + ".ini");
			mMtkTvFApiSystem.setEmmcEnvVar("db_table", "0");*/
            mMtkTvFApiDisplay.setPanelIni(Contants.FACTORY_PAGE2_PANEL_PATH + name + ".ini");
        }
    }

    public boolean setPanelIndex(int value) {
        boolean bResult = false;
        // zcj 2018-10-30 if(mTvMiscManager !=null){
        // bResult =miscManager.selectPanelWithindex(value);
        // zcj 2018-10-30 }
        Log.v(TAG, "setPanelIndex =" + value);
        return bResult;
    }

    public String getCurProductName() {
        // zcj 2018-10-30 return mTvMiscManager.getProductName();
        return "null";
    }

    public void saveProductName(String name) {
        if (name != null) {
            // zcj 2018-10-30 mTvMiscManager.setProductName(name);
        }
    }

    /*
     * //zcj 2018-10-30 public PanelInfo getPanelInfo(){ return
     * mTvMiscManager.getPanelInfo(null); }
     */

    public String getPQVersion() {
        String PQStr = "0.0";
        if (mMtkTvFApiDisplay != null) {
            PQStr = mMtkTvFApiDisplay.getPQVersion(0);
        }
        if (PQStr == null) {
            PQStr = "0.0";
        }
        return PQStr;
    }

    public String getAQVersion() {
        String AQStr = "0.0";
        if (mMtkTvFApiInformation != null) {
            AQStr = mMtkTvFApiInformation.getIniParameter(
                    Contants.FACTORY_PAGE1_AQ_VERSION_PATH, Contants.FACTORY_INI_PANEL_VER);
        }

        return AQStr;
    }

    public String getFPVersion() {
        String FPStr = "0.0";
        if (mMtkTvFApiInformation != null) {
//            String mPanelPathStr = mMtkTvFApiInformation.getIniParameter(
//                    Contants.FACTORY_PAGE2_CUSTOMER_PATH,
//                    Contants.FACTORY_INI_PANEL_PATH);
            String mDataIndexPathStr=getDataIndex();
            String mPanelPathStr = mMtkTvFApiInformation.getIniParameter(mDataIndexPathStr,Contants.FACTORY_INI_PANEL_PATH);
            Log.d(TAG, "mPanelPathStr:" + mPanelPathStr);
            Log.d(TAG,"mDataIndex:"+mDataIndexPathStr);
            FPStr = mMtkTvFApiInformation.getIniParameter(mPanelPathStr,
                    Contants.FACTORY_INI_PANEL_VER);
        }
        Log.d(TAG, "FPStr:" + FPStr);
        return FPStr;
    }

    public String getDataIndex(){
        String pid=getProjectIndex();
        if(!TextUtils.isEmpty(pid)) {
            String mDataIndexPathStr = Contants.FACTORY_DATAINDEX_PATH + "dataIndex_" + pid + ".ini";
            return mDataIndexPathStr;
        }
        return "";
    }

    public String getTvosVersion() {
        // TODO Auto-generated method stub
        String TvosStr = "0.0";
        // mMtkTvFApiInformation.getIniParameter(path, key)
        return TvosStr;
    }

    public String getMDWVersion() {
        // TODO Auto-generated method stub

        String MDWStr = "0.0";
        /*
         * //zcj 2018-10-30CHMWVersion MDWVersion =null; if(mTvMiscManager
         * !=null){ MDWVersion = mTvMiscManager.getCHMWSVersion(); }
         * if(MDWVersion !=null){ MDWStr ="Time:"+MDWVersion.mReleaseDate
         * +" Version:" +MDWVersion.mHwVersion +"."+MDWVersion.mMajor
         * +"."+MDWVersion.mMinor; }else{ Log.v("tv","getCHMWSVersion =null"); }
         */

        return MDWStr;
    }

    public String getDataVersion() {
        String version = "version";
        if(FactorySetting.isDataIndexExistVersion()){
            version=Contants.FACTORY_DATAINDEX_DATAVERSION;
        }else {
            version = mMtkTvFApiInformation.getIniParameter(
                    Contants.FACTORY_PAGE2_CUSTOMER_PATH,
                    Contants.FACTORY_INI_PANEL_VER);
        }
        Log.d(TAG,"version="+version+"|Contants="+Contants.FACTORY_DATAINDEX_DATAVERSION);
        return version;

    }

    public String getNetActive() {
        String netActiveStr = null;
        String ActiveDate = null;
        /*
         * //zcj 2018-10-30if(mTvMiscManager !=null){ //netActiveStr
         * =miscManager.getNetActive(); ActiveDate =
         * Settings.Secure.getString(mContext.getContentResolver(),
         * "ActiveDate"); } if(ActiveDate ==null ||
         * ActiveDate.equalsIgnoreCase("")) { netActiveStr =
         * mContext.getResources
         * ().getString(R.string.factory_net_notactive_string);//"δ����"; }
         * else{ netActiveStr = ActiveDate;//"����ʱ��:"+ActiveDate; }
         */

        return netActiveStr;
    }

    public void selectPanelWithName(String strPanelName) {
        // zcj 2018-10-30 if(mTvMiscManager !=null){
        // selectProductWithName.selectPanelWithName(strPanelName);
        // zcj 2018-10-30}
    }

    public void selectProductWithName(String strProductName) {
        // zcj 2018-10-30if(mTvMiscManager !=null){
        // mTvMiscManager.selectProductWithName(strProductName);
        // zcj 2018-10-30}
    }

    public int setProductManualNetAct() {
        // InfoCollectFile mInfoCollectFile;
        // mInfoCollectFile = InfoCollectFile.getInstance(mContext);
        // int ret=mInfoCollectFile.send("POSTACTIVE", "2");
        return 0;// ret;
    }

    public int setShopManualNetAct(String mInputStr) {
        // InfoCollectFile mInfoCollectFile;
        // mInfoCollectFile = InfoCollectFile.getInstance(mContext);
        // int ret=mInfoCollectFile.send("POSTACTIVE", "3" ,mInputStr);
        return 0;// ret;
    }

    public int getProductType() {
        // TODO Auto-generated method stub
        // zcj 2018-10-30return mTvMiscManager.getCurrentProductIsCH(); //ch
        // chiq oboni
        return 1;
    }

    public String get6m40Version() {
        // TODO Auto-generated method stub
        // zcj 2018-10-30return mTvMiscManager.get6M40Version();
        return "null";
    }

    public String getPanelSize() {
        // TODO Auto-generated method stub
        // zcj 2018-10-30return mTvMiscManager.getCurrentProductPanelSize()+"";
        return "null";
    }

    public String getBootVersion() {
        // TODO Auto-generated method stub
        // zcj 2018-10-30return mTvMiscManager.getMBootVersion();
        // mMtkTvFApiSystem.getEmmcEnvVar(key)
        return "null";
    }

    /**
     * zcj
     ************/
    public boolean isHDCPKey1XExist() {
        // TODO Auto-generated method stub
        if (mMtkTvFApiSystem != null) {
            return mMtkTvFApiSystem
                    .checkSystemKey(MtkTvFApiKeyManager.EnumSystemKeyType.E_MTK_FAPI_SYSTEM_KEY_HDCP14);
        }

        /*
         * File hdcpFile=new File(Contants.KEY_PATH_HDCP14); return
         * hdcpFile.exists();
         */
        return false;
    }

    public boolean isHDCPKey2XExist() {
        // TODO Auto-generated method stub
        if (mMtkTvFApiSystem != null) {
            return mMtkTvFApiSystem.isFileExist(Contants.KEY_PATH_HDCP2);
			/*return mMtkTvFApiSystem
					.checkSystemKey(MtkTvFApiKeyManager.EnumSystemKeyType.E_MTK_FAPI_SYSTEM_KEY_HDCP2);*/
        }
        return false;
    }

    public boolean isDTVCIPlusKeyExist() {
        // TODO Auto-generated method stub
        boolean ret=MtkTvCI.getInstance(0).getCIKeyStatus();
        if(ret) {
            if (mMtkTvFApiSystem != null) {
                return mMtkTvFApiSystem
                        .checkSystemKey(MtkTvFApiKeyManager.EnumSystemKeyType.E_MTK_FAPI_SYSTEM_KEY_CIPLUS);
            }
        }
        return false;
    }

    public boolean isWidevineKeyExist() {
        // TODO Auto-generated method stub
        if (mMtkTvFApiSystem != null) {
            return mMtkTvFApiSystem
                    .checkSystemKey(MtkTvFApiKeyManager.EnumSystemKeyType.E_MTK_FAPI_SYSTEM_KEY_WVCENC);
        }
        return false;
    }

	public boolean isNETFLIXKeyExist() {
		// TODO Auto-generated method stub
		if (mMtkTvFApiSystem != null) {
			return (mMtkTvFApiSystem.checkSystemKey(MtkTvFApiKeyManager.EnumSystemKeyType.E_MTK_FAPI_SYSTEM_KEY_NETFLIX50)
					&& mMtkTvFApiSystem.isFileExist(Contants.KEY_PATH_NETFLIX_KEY)
					&& mMtkTvFApiSystem.isFileExist(Contants.KEY_PATH_NETFLIX_ESN_KEY));
		}
		return false;
	}
	
	public boolean isESNIDExist() {
		// TODO Auto-generated method stub
		if (mMtkTvFApiSystem != null) {
                        
			return  mMtkTvFApiSystem.isFileExist(Contants.KEY_PATH_NETFLIX_ESN_KEY);
		}
		return false;
	}

    public boolean isKeyMasterExist() {
        // TODO Auto-generated method stub
        if (mMtkTvFApiSystem != null) {
            return mMtkTvFApiSystem
                    .checkSystemKey(MtkTvFApiKeyManager.EnumSystemKeyType.E_MTK_FAPI_SYSTEM_KEY_KEYMASTER);
        }
        return false;
    }

    public boolean isPlayReadyExist() {
        if (mMtkTvFApiSystem != null) {
            return mMtkTvFApiSystem
                    .checkSystemKey(MtkTvFApiKeyManager.EnumSystemKeyType.E_MTK_FAPI_SYSTEM_KEY_PLAYREADY30);
        }
        return false;
    }
    
    public boolean isPlayReady25Exist() {
        if (mMtkTvFApiSystem != null) {
            return mMtkTvFApiSystem
                    .checkSystemKey(MtkTvFApiKeyManager.EnumSystemKeyType.E_MTK_FAPI_SYSTEM_KEY_PLAYREADY25);
        }
        return false;
    }

    public boolean isHashKeyExist() {
        File hashFile = new File(Contants.KEY_PATH_HASH_KEY);
        return hashFile.exists();
    }
    
    public boolean isCLIENTCAKeyExist() {
        File hashFile = new File(Contants.KEY_PATH_WEBPLATFORM_CA);
        return hashFile.exists();
    }

    public boolean isProjectIdExist() {
        return mMtkTvFApiSystem.isFileExist(Contants.PATH_PROJECT_INI);
    }

    public boolean isHdcp2xKeyNeeded() {
        String platform = "";
        try {
            Process mProcess = Runtime.getRuntime().exec("getprop ro.board.platform");
            InputStreamReader inputStreamReader = new InputStreamReader(mProcess.getInputStream());
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
            platform = bufferedReader.readLine();
            if (platform.equalsIgnoreCase("m7632") || platform.equalsIgnoreCase("m7332")) {
                if(mProduct.contains("61")){
                    //isdb61 is 2K model
                    return false;
                }
                return true;
            } else if (platform.equalsIgnoreCase("mt5867")) {
                return false;
            } else {
                return false;
            }
        } catch (IOException e) {
            return false;
        }
    }

    public boolean isCIKeyNeeded() {
        boolean mode = false;
        String str = null;

        str = MtkTvFApiInformation.getInstance().getIniParameter(
                Contants.PATH_CUSTOM_FUNC_INI, Contants.FACTORY_CI_ENABLE);
        Log.d(TAG, str);
        if (str != null) {
            mode = str.equalsIgnoreCase("1") ? true : false;
        } else {
            mode = false;
        }
        if (mProduct.contains("ISDB")||mProduct.contains("ATSC")){
            mode =false;
        }
        return mode;

    }
    
    public boolean isESNKeyNeeded() {
        boolean mode = false;
        if(isHdcp2xKeyNeeded()){
        	String str = null;

            str = MtkTvFApiInformation.getInstance().getIniParameter(
                    Contants.PATH_FACTORYINI, Contants.FACTORY_ESN_CONFIG);
            
            if (str.equalsIgnoreCase("1") ||  str.equalsIgnoreCase("0")) {
                mode = str.equalsIgnoreCase("1") ? true : false;
            } else {
                mode = true;
            }
        }else {
			String str1 = null;

            str1 = MtkTvFApiInformation.getInstance().getIniParameter(
                    Contants.PATH_FACTORYINI, Contants.FACTORY_ESN_CONFIG);
            
            if (str1.equalsIgnoreCase("1") ||  str1.equalsIgnoreCase("0")) {
                mode = str1.equalsIgnoreCase("1") ? true : false;
            } else {
                mode = false;
            }
		}
        return mode;

    }
    
    public boolean isPlayReadyKey25Needed() {
        boolean mode = false;
        String str = null;

        str = MtkTvFApiInformation.getInstance().getIniParameter(
                Contants.PATH_CUSTOM_FUNC_INI, Contants.FACTORY_HBBTV_ENABLE);
        Log.d(TAG, str);
        if (str != null) {
            mode = str.equalsIgnoreCase("1") ? true : false;
        } else {
            mode = false;
        }

        if(mProduct.contains("ATSC")||mProduct.contains("ISDB")){
            mode=false;
        }
        return mode;

    }

    /**
     * zcj end
     ************/
    public int getEepromTypeSize() {
        // TODO Auto-generated method stub
        // zcj 2018-10-30Log.v("tv","eeprom_type_sie="+
        // mTvMiscManager.getEepromType());
        // zcj 2018-10-30return mTvMiscManager.getEepromType();
        return 1;
    }

    public boolean GetWithDTV() {
        // TODO Auto-generated method stub
        /*
         * //zcj 2018-10-31 String
         * res=SystemProperties.get("persist.sys.withdtv");
         * Log.v("tv","SystemProperties.get persist.sys.withdtv"+res);
         * if(res.equalsIgnoreCase("false")){ return false; }else
         * if(res.equalsIgnoreCase("true")){ return true; }
         */

        return true;
    }

    public String GetFirmwareTag() {
        // TODO Auto-generated method stub
        /*
         * //zcj 2018-10-31 String
         * res=SystemProperties.get("ro.build.firmwaretag");
         * Log.v("tv","SystemProperties.get ro.build.firmwaretag"+res);
         * if(res.equalsIgnoreCase("")||!res.startsWith("HLS71")){ return
         * "HLS71"; }else { return res; }
         */
        return "null";

    }

    public String getProjectIndex() {
        String name = mMtkTvFApiInformation.getIniParameter(Contants.PATH_PROJECT_INI, Contants.FACTORY_PROJECT_ID);
        String pid=mMtkTvFApiSystem.getEmmcEnvVar("CUSDATA_PROJECT_ID");

        if (pid == null) {
            if(name!=null && name.length()!=0){
                pid=name;
                Log.v(TAG, "getProjectIndex name=" + pid);
            }else{
                pid="0";
                Log.v(TAG, "getProjectIndex can not find project id");
            }
        }
        Log.v(TAG, "getProjectIndex pid=" + pid);
        return pid;
    }
    
    public String getIrModel() {
        String IrStr = "unKnow";
        if (mMtkTvFApiInformation != null) {
            IrStr = mMtkTvFApiInformation.getIniParameter(
                    Contants.PATH_IR_CONFIG, Contants.FACTORY_INI_IR_MODEL);
        }

        return IrStr;
    }

    public String getPQIniVersion(){
        String mPath="";
        if(TextUtils.isEmpty(Contants.FACTORY_PAGE1_HSYPQBIN_PATH)) {
            mPath=Contants.FACTORY_PAGE2_PQ_PATH;
        }else{
            mPath=Contants.FACTORY_PAGE1_HSYPQBIN_PATH;
        }
        if(!TextUtils.isEmpty(mPath)) {
            mPath=mPath.substring(0,mPath.lastIndexOf("/"));
            mPath=mPath.substring(0,mPath.lastIndexOf("/"));
            mPath=mPath.substring(0,mPath.lastIndexOf("/")+1);

            String PQIniVerPath = mPath + Contants.FACTORY_PQINI_VERSION;
            Log.d("CHFactory","PQ_ini_Version="+PQIniVerPath);
            Log.d("CHFactory","HSYPQBinPathName="+Contants.FACTORY_PAGE1_HSYPQBIN_PATH);
            String ver = "";
            ver=MtkTvFApiInformation.getInstance().getIniParameter(
                    PQIniVerPath, Contants.FACTORY_INI_PANEL_VER);

            return ver;
        }else{
            return "";
        }
    }

    public String getShowModePlay(){
        String value = mMtkTvFApiInformation.getIniParameter(
                Contants.PATH_FACTORYINI, Contants.FACTORY_INI_SHOW_MODE_PLAY);
        if(TextUtils.isEmpty(value)){
            value="0";
        }
        return value;
    }
    public void setShowModePlay(String val){
        mMtkTvFApiInformation.setIniParameter(
                Contants.PATH_FACTORYINI, Contants.FACTORY_INI_SHOW_MODE_PLAY,val);
    }

    public boolean isColRegion() {
        String mModel=SystemProperties.get("ro.product.model", "AI PONT");
        if(mModel.equalsIgnoreCase("AI PONT CO")){
            Log.d(TAG,"isColRegion:"+mModel);
            return true;
        }else{
            return false;
        }
    }

    public ArrayList<String> getProjectIdTotalList(){
        Log.d(TAG,"getProjectIdTotalList");
        ArrayList<String> List=mMtkTvFApiSystem.getProjectIdTotalList();
        return List;
    }
	
	public String getTconBinVer(){
        String ver=MtkTvFApiInformation.getInstance().getIniParameter(
                Contants.FACTORY_TCONCFGFILE, Contants.FACTORY_INI_PANEL_VER);
        return ver;
    }

    public int getTconEnable(){
        String enable=MtkTvFApiInformation.getInstance().getIniParameter(
                Contants.FACTORY_EXTRA_BOARD_PATH, Contants.FACTORY_TCONLESS_ENABLE);
        int ret;
        if(TextUtils.isEmpty(enable)){
            ret=0;
        }else{
            ret=Integer.parseInt(enable);
        }
        return ret;
    }

    public int getLDMEnable(){
        String enable=MtkTvFApiInformation.getInstance().getIniParameter(
                Contants.FACTORY_EXTRA_BOARD_PATH, Contants.FACTORY_LDM_ENABLE);
        int ret;
        if(TextUtils.isEmpty(enable)){
            ret=0;
        }else{
            ret=Integer.parseInt(enable);
        }
        return ret;
    }

    public int setTconEnable(int enable){
        int ret=MtkTvFApiInformation.getInstance().setIniParameter(
                Contants.FACTORY_EXTRA_BOARD_PATH, Contants.FACTORY_TCONLESS_ENABLE, ""+enable);
        return ret;
    }
}